//
//  WeatherTableViewCell.m
//  pocketNews
//
//  Created by DS on 2018/10/31.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "WeatherTableViewCell.h"
#import "MLMProgressView.h"

#import "MLMCircleView.h"

#import "BezierPathView.h"



#import "ZCCCircleProgressView.h"


@interface WeatherTableViewDayCell()

Strong UIImageView * picImageView;



Strong UILabel * weatherLabel;

Strong UILabel * tempLabel;

Strong UIView * lineView;


@end

@implementation WeatherTableViewDayCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _picImageView = [UIImageView addImgWithImage:@"logohong"];
        
        _dayLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"今天" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _weatherLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"晴天" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"696969")];
        _tempLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"1/11" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"696969")];
        
        _lineView = [UIView addLineViewColor:getColor(dividerColor)];
        
        [self sd_addSubviews:@[self.picImageView,self.dayLabel,self.weatherLabel,self.tempLabel,self.lineView]];
        
        [self layOutFrame];
    }
    
    return self;
}

- (void)layOutFrame{
    ws(self)
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(UNIT_WIDTH(10));
        make.centerY.mas_equalTo(weakself.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        make.width.mas_equalTo(UNIT_WIDTH(30));
        
    }];
    
    [self.dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_HEIGHT(10));
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(20));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
    }];
    
    [self.weatherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(20));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        
    }];
    
    [self.tempLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-10));
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        make.centerY.mas_equalTo(weakself.mas_centerY);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(UNIT_HEIGHT(5));
    }];
    
}

- (void)setModel:(WeatherNowModel *)model{
    
    _model = model;
    
    self.weatherLabel.text = model.cond_txt_n;
   
    self.tempLabel.text = [NSString stringWithFormat:@"%@°C/%@°C",model.tmp_min,model.tmp_max];
    
    
}

@end


@interface WeatherTableViewStatusCell ()




@end

@implementation WeatherTableViewStatusCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
       self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _firstView = [UIView addViewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH / 4, SCREEN_WIDTH / 4) WithBackgroundColor:getColor(whiteColor)];
        
        _twoView = [UIView addViewWithFrame:CGRectMake(SCREEN_WIDTH / 4, 0, SCREEN_WIDTH / 4, SCREEN_WIDTH / 4) WithBackgroundColor:getColor(whiteColor)];
        
        _threeView = [UIView addViewWithFrame:CGRectMake(SCREEN_WIDTH / 4 * 2, 0, SCREEN_WIDTH / 4, SCREEN_WIDTH / 4) WithBackgroundColor:getColor(whiteColor)];
        
        _fourView = [UIView addViewWithFrame:CGRectMake(SCREEN_WIDTH / 4 * 3, 0, SCREEN_WIDTH / 4, SCREEN_WIDTH / 4) WithBackgroundColor:getColor(whiteColor)];
        
          _lineView = [UIView addViewWithFrame:CGRectMake(0, SCREEN_WIDTH / 4, SCREEN_WIDTH, UNIT_HEIGHT(5)) WithBackgroundColor:getColor(dividerColor)];
        
        [self sd_addSubviews:@[self.firstView,self.twoView,self.threeView,self.fourView,self.lineView]];
        
        _windLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"南风" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _windNumLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"二级" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _windlineView = [UIView addViewWithFrame:CGRectMake(0, 0, 0, 0) WithBackgroundColor:getColor(@"696969")];
        
      
       
        [_firstView sd_addSubviews:@[self.windLabel,self.windNumLabel,self.windlineView]];
        
        ws(self)
        [self.windLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(weakself.firstView.mas_top).offset(UNIT_HEIGHT(15));
            make.centerX.mas_equalTo(weakself.firstView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.windNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
             make.bottom.mas_equalTo(weakself.firstView.mas_bottom).offset(UNIT_HEIGHT(-15));
            make.centerX.mas_equalTo(weakself.firstView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.windlineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(10));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
            make.width.mas_equalTo(1);
            make.right.mas_equalTo(0);
        }];
        
        
        _codeLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"相对湿度" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _numCodeLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"71" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _numLineView = [UIView addViewWithFrame:CGRectMake(0, 0, 0, 0) WithBackgroundColor:getColor(@"696969")];
     
        [self.twoView sd_addSubviews:@[self.codeLabel,self.numCodeLabel,self.numLineView]];
        
        [self.codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(weakself.twoView.mas_top).offset(UNIT_HEIGHT(15));
            make.centerX.mas_equalTo(weakself.twoView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.numCodeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.mas_equalTo(weakself.twoView.mas_bottom).offset(UNIT_HEIGHT(-15));
            make.centerX.mas_equalTo(weakself.twoView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.numLineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(10));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
            make.width.mas_equalTo(1);
            make.right.mas_equalTo(0);
        }];
        
        
        
        _tempLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"体感温度" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _tempNumLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"6" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _tempView = [UIView addViewWithFrame:CGRectMake(0, 0, 0, 0) WithBackgroundColor:getColor(@"696969")];
        
        [self.threeView sd_addSubviews:@[self.tempLabel,self.tempNumLabel,self.tempView]];
        
        [self.tempLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(weakself.threeView.mas_top).offset(UNIT_HEIGHT(15));
            make.centerX.mas_equalTo(weakself.threeView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.tempNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.mas_equalTo(weakself.threeView.mas_bottom).offset(UNIT_HEIGHT(-15));
            make.centerX.mas_equalTo(weakself.threeView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.tempView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(UNIT_HEIGHT(10));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
            make.width.mas_equalTo(1);
            make.right.mas_equalTo(0);
        }];
        
        
        _pressLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"气压" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
        _pressNumLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"6" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"111111")];
       
        
        [self.fourView sd_addSubviews:@[self.pressLabel,self.pressNumLabel]];
        
        [self.pressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.mas_equalTo(weakself.fourView.mas_top).offset(UNIT_HEIGHT(15));
            make.centerX.mas_equalTo(weakself.fourView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        [self.pressNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.mas_equalTo(weakself.fourView.mas_bottom).offset(UNIT_HEIGHT(-15));
            make.centerX.mas_equalTo(weakself.fourView.mas_centerX);
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
       
        
        
    }
    
    return self;
    
}



@end

//更多天气

@interface WeatherTableViewMoreCell()

Strong UIImageView * picImageView;

Strong UILabel * moreLabel;

@end

@implementation WeatherTableViewMoreCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        ws(self)
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.moreLabel = [UILabel addLabelWithFrame:CGRectMake(UNIT_WIDTH(10), UNIT_HEIGHT(10), SCREEN_WIDTH, UNIT_HEIGHT(30)) AndText:@"更多天气" AndFont:15 AndAlpha:1.0 AndColor:getColor(@"696969")];
        
        self.picImageView = [UIImageView addImgWithImage:@"banner_02"];
        
        [self sd_addSubviews:@[self.moreLabel,self.picImageView]];
        
        [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(weakself.moreLabel.mas_bottom).offset(10);
            make.left.mas_equalTo(UNIT_WIDTH(10));
            make.right.mas_equalTo(UNIT_WIDTH(-10));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
        }];
        
       
    }
    
    return self;
}



@end

//比较舒服

@interface WeatherTableViewComCell()



@end


@implementation WeatherTableViewComCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _picImageView = [UIImageView addImgWithImage:@"xiaolian1"];
        
        _titleLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"较舒适" AndFont:13 AndAlpha:1.0 AndColor:getColor(@"696969")];
        
        _contentLabel = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"白天自然天气晴好,但早晚会感觉偏凉,午后舒适,宜人" AndFont:13 AndAlpha:1.0 AndColor:getColor(@"696969")];
        _contentLabel.numberOfLines = 0;
        
        [self sd_addSubviews:@[self.picImageView,self.titleLabel,self.contentLabel]];
        
        [self layOutFrame];
        
    }
    
    return self;
}

- (void)layOutFrame{
    ws(self)
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(10));
        make.centerY.mas_equalTo(weakself.mas_centerY);
        make.height.mas_equalTo(UNIT_WIDTH(22));
        make.width.mas_equalTo(UNIT_WIDTH(22));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakself.picImageView.mas_right).offset(UNIT_WIDTH(10));
        make.centerY.mas_equalTo(weakself.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(30));
        make.width.mas_equalTo(UNIT_WIDTH(60));
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(UNIT_HEIGHT(10));
        make.right.mas_equalTo(UNIT_WIDTH(-10));
        make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
        make.left.mas_equalTo(weakself.titleLabel.mas_right).offset(UNIT_WIDTH(10));
    }];
    
    
    
}


@end


//进度条

@interface WeatherTableViewProgerssCell()

Strong UIView * lineView;

Strong CAShapeLayer *pathLayer;

Strong UIButton * goBuyBtn;

Strong UIBezierPath *path;

@property (nonatomic, weak)ZCCCircleProgressView *circleProgress;



@end

@implementation WeatherTableViewProgerssCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    if (self = [super initWithCellIdentifier:cellID]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        

        // [self drawRect:self.bounds];
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(dividerColor);
        
        [self addSubview:self.lineView];

        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.right.mas_equalTo(0);
            make.height.mas_equalTo(1);
            make.bottom.mas_equalTo(0);
        }];
        
//        _pointView1 = [[UIView alloc] init];
//        _pointView1.backgroundColor = [UIColor greenColor];
//        _pointView1.layer.cornerRadius = 5;
//        _pointView1.layer.masksToBounds = YES;
//
//        _pointView2 = [[UIView alloc] init];
//        _pointView2.backgroundColor = [UIColor greenColor];
//        _pointView2.layer.cornerRadius = 5;
//        _pointView2.layer.masksToBounds = YES;
        
        _sunLabel1 = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"日出17:32" AndFont:14 AndAlpha:1.0 AndColor:[UIColor orangeColor]];
        _nightLabel2 = [UILabel addLabelWithFrame:CGRectMake(0, 0, 0, 0) AndText:@"日落17:32" AndFont:14 AndAlpha:1.0 AndColor:[UIColor orangeColor]];
        
        
        
        ws(self)
        
//        [self.pointView1 mas_makeConstraints:^(MASConstraintMaker *make) {
//
//            make.left.mas_equalTo(25);
//            make.top.mas_equalTo(140);
//            make.height.mas_equalTo(10);
//            make.width.mas_equalTo(10);
//
//
//        }];
//
//
//        [self.pointView2 mas_makeConstraints:^(MASConstraintMaker *make) {
//
//            make.left.mas_equalTo(SCREEN_WIDTH - 35);
//            make.top.mas_equalTo(140);
//            make.height.mas_equalTo(10);
//            make.width.mas_equalTo(10);
//
//
//        }];
        
       
        
        ZCCCircleProgressView *circleProgress = [[ZCCCircleProgressView alloc] initWithFrame:CGRectMake(50, 20, SCREENWIDTH - 100, 170)];
        
        self.circleProgress = circleProgress;
        
        [self addSubview:circleProgress];
        
        [circleProgress addCircleWithColor:[UIColor purpleColor]];
        
     
        //[circleProgress animateToProgress:0.8];
        
        
        [circleProgress sd_addSubviews:@[self.sunLabel1,self.nightLabel2]];
        
        
        [self.sunLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(UNIT_WIDTH(25));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
            
        }];
        
        [self.nightLabel2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(UNIT_WIDTH(-25));
            make.bottom.mas_equalTo(UNIT_HEIGHT(-10));
            make.height.mas_equalTo(UNIT_HEIGHT(30));
        }];
        
        

        
    }
    
    return self;
}


- (void)setScale:(CGFloat)scale{
    
    _scale = scale;
    
    
    [self.circleProgress animateToProgress:scale];
    
}


@end

